package cn.idietrade.idietradelogisticsmanage8007.demo.controller;

import cn.idietrade.common.pojo.SecondLogisticsCompany;
import cn.idietrade.common.pojo.SecondUser;
import cn.idietrade.common.utils.RedisUtil;
import cn.idietrade.common.utils.ReturnResultData;
import cn.idietrade.idietradelogisticsmanage8007.demo.service.CompanyManageService;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author 作者：李永康
 * @createTime 2022/12/5 15:08
 * @description 描述
 */
@RestController
public class CompanyManageController {
    @Resource
    private CompanyManageService companyManageService;
    //审核物流公司状态
    @RequestMapping("/companyState")
    public ReturnResultData updateState(@RequestParam Integer id,@RequestParam Integer exc){
       // SecondUser secondUser = JSON.parseObject(redisUtil.getStr(token), SecondUser.class);

        ReturnResultData resultData=new ReturnResultData();
        if(exc > 0){
            resultData.setData(companyManageService.companyState(id));
            resultData.setMessage("公司审核成功");
            resultData.setCode(1);
        }else{
            resultData.setMessage("公司审核失败");
            resultData.setCode(0);
        }
        return resultData;
    }
    //查询所有未审核的物流公司
    @RequestMapping("/queryAllCompany")
    public PageInfo<SecondLogisticsCompany> getAll( @RequestParam(required = false) Integer pageNum, @RequestParam(required = false) Integer pageSize){


        return companyManageService.queryAll(pageNum,pageSize);
    }
}
